<template>
	<view>
		<view style="background-image: url('/static/images/ceping/wjdc-bg@2x.png');width: 100%;height: 297upx;background-repeat: no-repeat;background-size: 100% 100%;text-align: center;padding-top: 90upx;z-index: 1;">
			<!-- <image src="/static/images/ceping/wjdc-bg@2x.png" style="width: 100%;height: 297upx;" mode="scaleToFill"></image> -->
			<span style="font-size: 60upx;font-family: FZZongYi-M05S, FZZongYi-M05S-Regular;font-weight: 400;color: #ffffff;text-shadow: -4px 4px 0px NaNpx rgba(0,0,0,0.15);">心理测试问卷</span>
		</view>
		<view style="position: relative;">
			<view style="position: absolute;top: -40upx;z-index: 999;width: 100%;border-top-right-radius: 20upx;border-top-left-radius: 20upx;background: #FFFFFF;">
				<view v-for="(item, index) in detail" :key="index" style="padding: 20upx;">
					<!-- <view>
						<u-parse :content="item.desc" @navigate="navigate"></u-parse>
					</view> -->
					<view style="width: 376px;font-size: 32upx;font-family: PingFang SC, PingFang SC-Bold;font-weight: 700;color: #000000;">
						{{item.sort}}.{{item.title}}
					</view>
					<view class="uni-list">
						<radio-group @change="radioChange($event, index)">
							<label class="uni-list-cell uni-list-cell-pd" v-for="(itemed, indexed) in item._answers" :key="itemed.value">
								<view style="font-size: 28upx;font-family: PingFang SC, PingFang SC-Medium;font-weight: 500;color: #000000;">
									<radio style="transform:scale(0.7)" :value="itemed.hidden_value" :checked="index === current" color="#0097ff" />{{itemed.title}}
								</view>
							</label>
						</radio-group>
					</view>
				
				</view>
				
				<view style="width: 100%;padding: 30upx;">
					
					<view style="height: 60upx;display: flex;align-items: center;justify-content: center;background: #0097ff;border-radius: 40upx;color: #FFFFFF;" @click="goSubmit()">
						<span>提交</span>
					</view>
				</view>
			</view>
			
			
			
		</view>
	</view>
</template>

<script>
	import uParse from "@/components/feng-parse/parse.vue";
	export default {
		data() {
			return {
				detail:{},
				eid:'',
				items:[]
			};
		},
		components:{
		            uParse
		        },
		
		onLoad(options){
			this.eid = options.id
			this.loadData(options.id)		
		},
		 
		methods: {
			//获取订单列表
			loadData(id){
				var that = this;
				that.$zdapi.getTestInfo({
					eid: id
				}).then( res => {
					that.detail = res.data
					that.items = res.data
				})	
			}, 
			
			goSubmit(){
				var that = this;
				let tmp = {
					uid: wx.getStorageSync('uid'),
					token: wx.getStorageSync('token'),
					test_id: that.detail[0].id,
					eval_id: that.eid,
					p:[],
					psort:[]
				};
				
				let p = [];
				let psort = [];
				
				this.items.forEach( item => {
						
					if(item.slelctValue){
						tmp.p.push(item.id)
						tmp.psort.push(item.sort)
						let tt = 'ans_'+item.id
						
						tmp[tt] = item._answers[item.slelctValue-1].hidden_value
					}
					
				})
				// tmp.p = p;
				// tmp.psort = psort;
				
				// return
				
				that.$zdapi.getSubmits(tmp).then( res => {
					
				})	
			},
			
			radioChange: function(evt, index) {
				var that = this;
			            console.log("111111111")
						console.dir(evt)
						console.dir(index)
						that.items[index].slelctValue = evt.detail.value
			        }
		}
	}
</script>


<style>
	@import url("../../components/feng-parse/parse.css");
	*{
		box-sizing: border-box;
	}
	page{
		background: #EDEFF2;
		height: 100%;
	}
	.perItem{
		width: 100%;
		height: 150upx;
		border-radius: 15upx;
		background: #ffffff;
		display: flex;
		align-items: center;
	}
</style>
